package com.ruoyi.buss.expand.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.enums.ErrorCode;
import com.ruoyi.common.core.exception.CustomException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.expand.domain.DataCustExpand;
import com.ruoyi.buss.expand.service.IDataCustExpandService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 跟进拓展信息Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/expand")
public class DataCustExpandController extends BaseController
{
    @Autowired
    private TokenService tokenService;

    @Autowired
    private IDataCustExpandService dataCustExpandService;

    /**
     * 查询跟进拓展信息列表
     */
    @PreAuthorize(hasPermi = "buss:expand:list")
    @GetMapping("/queryExpandCustomerList")
    public TableDataInfo list(DataCustExpand dataCustExpand)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<DataCustExpand> list = dataCustExpandService.selectDataCustExpandList(dataCustExpand,userInfo);
        return getDataTable(list);
    }

    /**
     * 新增跟进拓展信息
     */
    @PreAuthorize(hasPermi = "buss:expand:addExpandCustomer")
    @Log(title = "addExpandCustomer", businessType = BusinessType.INSERT)
    @PostMapping("addExpandCustomer")
    public AjaxResult add(@Validated @RequestBody DataCustExpand dataCustExpand)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        return toAjax(dataCustExpandService.insertDataCustExpand(dataCustExpand,userInfo));
    }

    /**
     * 取消根据拓展客户
     */
    @PreAuthorize(hasPermi = "buss:expand:canelExpandCustomer")
    @Log(title = "canelExpandCustomer", businessType = BusinessType.INSERT)
    @PostMapping("canelExpandCustomer")
    public AjaxResult canelExpandCustomer(@Validated @RequestBody DataCustExpand dataCustExpand)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        return toAjax(dataCustExpandService.canelExpandCustomer(dataCustExpand,userInfo));
    }

}
